<!doctype html>
<html lang="">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" href="/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Vite App</title>
    <style></style>
  </head>
  <body>
    <ul>
      <li>123</li>
      <li>123</li>
      <li>123</li>
      <li>123</li>
      <li>123</li>
      <li>123</li>
      <li>123</li>
      <li>123</li>
    </ul>
    <script>
      // 事件委托
      const ul = document.querySelector('ul')
      ul.addEventListener('click', (e) => {
        const liList = document.querySelectorAll('li')
        for (const li of liList) {
          li.style.background = 'white'
        }
        e.target.style.background = 'pink'
      })
    </script>
  </body>
</html>
